package com.ruoyi.report.service.impl;

import com.ruoyi.report.domain.*;
import com.ruoyi.report.mapper.HanZaiCustomerInfoMapper;
import com.ruoyi.report.mapper.HanZaiHouseInfoMapper;
import com.ruoyi.report.service.HanZaiCustomerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: 憨憨爱崽崽
 * Name: CustomerInfoServiceImpl
 * Date: 2022/3/28
 * Time: 11:11
 **/
@Service
public class HanZaiCustomerInfoServiceImpl implements HanZaiCustomerInfoService {
    @Autowired
    private HanZaiCustomerInfoMapper customerInfoMapper;
    @Autowired
    private HanZaiHouseInfoMapper houseInfoMapper;

    /**
     * 查询客户资料
     *
     * @param custid 客户资料主键
     * @return 客户资料
     */
    @Override
    public HanZaiCustomerInfo selectCustomerInfoByCustid(Long custid)
    {
        return customerInfoMapper.selectCustomerInfoByCustid(custid);
    }

    /**
     * 查询客户资料列表
     *
     * @param customerInfo 客户资料
     * @return 客户资料
     */
    @Override
    public List<HanZaiCustomerInfo> selectCustomerInfoList(HanZaiCustomerInfo customerInfo) {
        List<HanZaiCustomerInfo> customerInfoList = customerInfoMapper.selectCustomerInfoList(customerInfo);
        for (HanZaiCustomerInfo customer : customerInfoList){
            HanZaiHouseInfo houseInfo = houseInfoMapper.selectHouseInfoByHouseId(customer.getProjectid());
            if (houseInfo != null){
                customer.setProjectName(houseInfo.getHouseName());
                customer.setSaleName(houseInfo.getSaleState());
            }
            //System.out.println(customer);
        }
        return customerInfoList;
    }

}
